public class problem45 {
    public static void main(String[] args) {
        for (int a=286; a<1000; a++) {
            int triangle = a*(a+1)/2;
            for (int b=0; b<1000; b++) {
                int pentagonal = b*(3*b-1)/2;
                for (int c=0; c<1000; c++) {
                    int hexagonal = c*(2*c-1);
                    System.out.println(triangle + " " + pentagonal + "  " + hexagonal);
                    if (triangle == pentagonal && pentagonal == hexagonal) {
                        System.out.println(triangle);
                    }
                }
            }
        }
    }
}
